/**
 * Created by Administrator on 2017/3/29 0029.
 */
var PageSound={
    create:function(){
        var page={};
        page.ui=new PIXI.DisplayObjectContainer();
        var bg=new PIXI.Graphics();
        bg.beginFill(0xffffff,1);
        bg.drawRect(0,0,740,1136);
        bg.endFill();
        page.ui.addChild(bg);

        var sp_bg=new PIXI.Sprite(resource['assets/images/pSound_bg.png'].texture);
        sp_bg.anchor.set(0.0);
        sp_bg.x = 0;
        sp_bg.y = 0;
        page.ui.addChild(sp_bg);

        sp_bg.on('pointerdown',downHandler);

        var sp_build=new PIXI.Sprite(resource['assets/images/pSound_build.png'].texture);
        sp_build.anchor.set(0.0);
        sp_build.x = 49;
        sp_build.y = 523;
        page.ui.addChild(sp_build);
        TweenMax.to(sp_build,1,{y:523+10,ease:Cubic.easeInOut,repeat:-1,yoyo:true});

        var click=new PIXI.Sprite(resource['assets/images/pSound_click.png'].texture);
        click.anchor.set(0.5);
        click.x = 382;
        click.y = 517;

        page.ui.addChild(click);

        var t0=new PIXI.Sprite(resource['assets/images/pSound_t0.png'].texture);
        t0.anchor.set(0,0.5);
        t0.x = 740;
        t0.y = 890;
        t0.alpha = 0;
        page.ui.addChild(t0);

        var t1=new PIXI.Sprite(resource['assets/images/pSound_t1.png'].texture);
        t1.anchor.set(0,0.5);
        t1.x = 740;
        t1.y = 890;
        t1.alpha = 0;
        page.ui.addChild(t1);

        var t2=new PIXI.Sprite(resource['assets/images/pSound_t2.png'].texture);
        t2.anchor.set(0,0.5);
        t2.x = 740;
        t2.y = 890;
        t2.alpha = 0;
        page.ui.addChild(t2);

        var t3=new PIXI.Sprite(resource['assets/images/pSound_t3.png'].texture);
        t3.anchor.set(0,0.5);
        t3.x = 740;
        t3.y = 890;
        t3.alpha = 0;
        page.ui.addChild(t3);

        //var t4=new PIXI.Sprite(resource['assets/images/pSound_t1.png'].texture);
        //t4.anchor.set(0.5);
        //t4.x = 0;
        //t4.y = 0;
        //page.ui.addChild(t4);

        var sp_title=new PIXI.Sprite(resource['assets/images/pSound_title.png'].texture);
        sp_title.x = 264;
        sp_title.y = 40;
        page.ui.addChild(sp_title);
        page.In=function()
        {
            sp_bg.alpha=0;
            TweenMax.to(sp_bg,1,{alpha:1});

            sp_title.y=0;
            sp_title.alpha=0;
            TweenMax.to(sp_title,1,{delay:1,y:40,alpha:1,ease:Cubic.easeInOut});
            click.alpha=0;
            click.scale.x=click.scale.y=0;
            TweenMax.to(click,1,{delay:2,alpha:1});
            TweenMax.to(click.scale,1,{delay:2,x:1,y:1,ease:Back.easeOut,onComplete:function()
            {
                sp_bg.interactive=true;
            }});

        }

        function downHandler(e)
        {
            TweenMax.to(click.scale,1,{delay:0,x:3,y:3,ease:Back.easeIn});
            TweenMax.to(click,1,{delay:0,alpha:0,ease:Back.easeIn});
            bg.interactive=false;
            threeInit();

            TweenMax.to(t0,1,{delay:1.5,x:100,alpha:1,ease:Cubic.easeOut});
            TweenMax.to(t0,2.5,{delay:2.5,x:-100,ease:Linear.easeNone});
            TweenMax.to(t0,1,{delay:5.0,x:-400,alpha:0,ease:Cubic.easeInOut,onComplete:function()
            {
                console.log('complete')
                ChangeLineColor(0xff0000);
            }});

            TweenMax.to(t1,1,{delay:5.5,x:100,alpha:1,ease:Cubic.easeOut});
            TweenMax.to(t1,2.5,{delay:6.5,x:-100,ease:Linear.easeNone});
            TweenMax.to(t1,1,{delay:9,x:-400,alpha:0,ease:Cubic.easeInOut,onComplete:function()
            {
                ChangeLineColor(0xffff00);
            }});

            TweenMax.to(t2,1,{delay:10,x:100,alpha:1,ease:Cubic.easeOut});
            TweenMax.to(t2,2.5,{delay:11,x:-100,ease:Linear.easeNone});
            TweenMax.to(t2,1,{delay:13.5,x:-400,alpha:0,ease:Cubic.easeInOut,onComplete:function()
            {
                ChangeLineColor(0x00ffff);
            }});

            TweenMax.to(t3,1,{delay:15,x:100,alpha:1,ease:Cubic.easeOut});
            TweenMax.to(t3,6,{delay:16,x:-100,ease:Linear.easeNone});
            TweenMax.to(t3,1,{delay:23,x:-400,alpha:0,ease:Cubic.easeInOut,onComplete:function()
            {
                ChangeLineColor(0xffffff);
            }});

            TweenMax.to(t3,1,{delay:2,onComplete:function()
            {
                var evt=new CustomEvent('Game_PageIn',{'detail':'0'});
                document.dispatchEvent(evt);
                threeOut();
            }});
        }

        return page;
    }
}